
"use strict";

angular.module('app.user').controller('ModifyInfoCtrl', function ($scope, userHttpS,$http,$cookieStore) {

    //var data = { oldpasswd: '111111', newpasswd1: '222222', newpasswd2: '222222' };
    
    $scope.data = {};
    
        $scope.modifyinfo = function () {
            // console.log($scope.data);
            if($scope.data.newpasswd1 != $scope.data.newpasswd2){
                alert('新密码两次输入不同');
            }
            //当旧密码正确 并且两次输入的新密码相同时
            //修改密码
            $http.put(baseurls+"/modifypass?id=="+$cookieStore.get("user"),{pass: $scope.data.newpasswd2,oldpass:$scope.data.oldpasswd}).then(function(res){
                // console.log(res.data);
                if(res.data.ret == 1){
                    new Notify('success','密码修改成功');
                    window.location.href = appConfig.base[0].baseURI + "#/per_user";
                }else{
                    // new Notify('fail','密码修改失败');
                    alert(res.data.info);
                }
            })
            
           
            
    
        }
    

});